package cn.edu.scau.cmi.wuyihan.adapter;

import java.util.ArrayList;
import java.util.List;

import cn.edu.scau.cmi.wuyihan.adapter.domain.Student;

public class AdapterOfObject implements Target{

	@Override
	public List sortStudent(List<Student> studentList) {
		
		int count = 0;
		SortUtil sortUtil = new SortUtil();
		List<Integer> numList = new ArrayList<>();
		List<Student> students = new ArrayList<>();
		
		for(Student student : studentList) {
			numList.add(student.getNum());
		}
		
		numList = sortUtil.sortInt(numList);
		
		for(Integer num : numList) {
			count = 0;
			while (count <= numList.size()) {
				if (studentList.get(count).getNum() == num) {
					students.add(new Student(num,studentList.get(count).getName()));
			        break;
				}
				count++;
			}
		}
		
		return students;
		
	}

}
